/*
 * @Author: szx
 * @Date: 2022-03-23 13:38:11
 * @LastEditTime: 2022-03-23 14:19:04
 * @Description:
 * @FilePath: \leetcode\剑指offer\33\33.js
 */
/**
 * @param {number[]} postorder
 * @return {boolean}
 */
var verifyPostorder = function (postorder) {
    //我tm直接单调栈
    const st = [];
    let parent = Infinity;
    for (let i = postorder.length - 1; i >= 0; i--) {
        while (st.length && postorder[i] < st[st.length - 1]) {
            parent = st.pop();
        }
        if (parent < postorder[i]) return false;
        st.push(postorder[i]);
    }
    return true;
};
